package it.polimi.swim.entity;
import java.io.Serializable;

import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQuery;
import javax.persistence.NamedQueries;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;

@NamedQueries({
	@NamedQuery(
		name="Skill.getAllSkills",
		query="SELECT s FROM Skill s WHERE s.status = 1"),
	@NamedQuery(
		name="Skill.getNotRegisteredSkill",
		query="SELECT s FROM Skill s WHERE s.status = 'false'"),
	@NamedQuery(
			name="Skill.getSkillById",
			query="SELECT s FROM Skill s WHERE s.id = :id"),
	@NamedQuery(
			name="Skill.getSkillByName",
			query="SELECT s FROM Skill s WHERE s.name = :name")

})

@Entity
@Table(name="Skill")
public class Skill implements Serializable{


	private static final long serialVersionUID = 4756968287794736138L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int id;
	
	@Column(name="name",nullable=false)
	private String name;
	
	@Column(name="status",nullable=false)
	private Boolean status;
	
	@ManyToMany(mappedBy="skillUser", fetch=FetchType.EAGER)
	List<SystemUser> skillUser;
	
    public List<SystemUser> getUsers() { return skillUser; }
	
    @OneToMany(mappedBy="necessarySkill")
	Set<HelpRequest> help;
    
    public Set<HelpRequest> getNecessarySkill() { return help; }
    
	//Set and Get
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Boolean getStatus() {
		return status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}
}